<?php

namespace App\Http\Controllers\Admin;

use App\Repository\Orders\OrdersLogisticsRepository as model;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller as BaseController;
use App\Repository\UploadRepository;
use App\Libs\PhpOffice\Excel;
use App\Repository\Shop\SuppilerRepository as supp;
use App\Repository\Order\OrderLogRepository as logModel;
use App\Api\Sms\TransferSms;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use App\Repository\Admin\AdminUsersRepository;
use App\Models\Orders\OrdersModel;

// 分销商
class OrderExpressController extends BaseController
{
  private $repoist;
  private $disModel;
  private $logModel;
  public function __construct(model $model, supp $supp, logModel $logModel)
  {
    $this->repoist = $model;
    $this->disModel = $supp;
    $this->logModel = $logModel;
  }
  public function store(Request $request)
  {
  }
  public function index(Request $request)
  {
  }

  public function sendYzm(Request $request)
  {
  }
  public function getPath(Request $request)
  {
  }
  public function getShow(Request $request)
  {
    if (empty($request->get('express_num'))) {
      return $this->returnMsg(101, '参数不能为空');
    }
    $where = [
      'express_num' => $request->get('express_num'),
    ];
    $res = $this->repoist->getOne($where);
    if ($res) {
      if (!empty($res['text'])) {
        $res['text'] = json_decode($res['text'], true);
      }
      return $this->returnMsg(200, '查询成功', $res);
    }
    return $this->returnMsg(103, '未查询到快递信息');
  }
  public function getExpressStatus()
  {
    $orderModel = new OrdersModel();
    $data = $orderModel->expressStatus();
    $resData = [];
    foreach ($data as $key => $v) {
      $resData[] = [
        'id' => $key,
        'value' => $v
      ];
    }
    return $this->returnMsg(200, '物流状态查询成功', $resData);
  }
}
